home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / machserver / 1.098 / dev / sun4.md / devSysgenTape.c < prev    next >
C/C++ Source or Header  |  1991-08-11  |  4KB  |  120 lines

  1. /* 
  2.  * devSCSISysgen.c --
  3.  *
  4.  *      Procedures that set up command blocks and process sense
  5.  *    data for Sysgen tape drives.
  6.  *
  7.  * Copyright 1986 Regents of the University of California
  8.  * All rights reserved.
  9.  */
  10.  
  11. #ifndef lint
  12. static char rcsid[] = "$Header: /sprite/src/kernel/dev/sun3.md/RCS/devSysgenTape.c,v 9.0 89/09/12 14:59:30 douglis Stable $ SPRITE (Berkeley)";
  13. #endif /* not lint */
  14.  
  15.  
  16. #include "sprite.h"
  17. #include "dev.h"
  18. #include "devInt.h"
  19. #include "scsi.h"
  20. #include "scsiDevice.h"
  21. #include "scsiHBA.h"
  22. #include "scsiTape.h"
  23. #include "fs.h"
  24. #include "sysgenTape.h"
  25.  
  26. /*
  27.  * Sense data returned from the Sysgen tape controller.
  28.  * This matches the ARCHIVE Sidewinder drive specifications, and the
  29.  * CIPHER Quarterback drive specifications.
  30.  */
  31. #define SYSGEN_SENSE_BYTES    16
  32. typedef struct {
  33.     /*
  34.      * Standard 4-bytes of sense data, not class 7 extended sense.
  35.      */
  36.     unsigned char valid        :1;    /* Sense data is valid */
  37.     unsigned char error        :7;    /* 3 bits class and 4 bits code */
  38.     unsigned char highAddr;        /* High byte of block address */
  39.     unsigned char midAddr;        /* Middle byte of block address */
  40.     unsigned char lowAddr;        /* Low byte of block address */
  41.     /*
  42.      * Additional 12 bytes of sense data specific to Sysgen drives.
  43.      */
  44.     unsigned char bitSet1    :1;    /* More bits set in this byte */
  45.     unsigned char noCartridge    :1;    /* The tape cartridge isn't there */
  46.     unsigned char noDrive    :1;    /* No such drive (check subUnitID) */
  47.     unsigned char writeProtect    :1;    /* The drive is write protected */
  48.     unsigned char endOfTape    :1;    /* End of tape encountered */
  49.     unsigned char dataError    :1;    /* Data error on the tape, fatal */
  50.     unsigned char noError    :1;    /* No error in the data */
  51.     unsigned char fileMark    :1;    /* File mark encountered */
  52.  
  53.     unsigned char bitSet2    :1;    /* More bits set in this byte */
  54.     unsigned char badCommand    :1;    /* A bad command was specified */
  55.     unsigned char noData    :1;    /* Counld't find the data */
  56.     unsigned char retries    :1;    /* Had to retry more than 8 times */
  57.     unsigned char beginOfTape    :1;    /* At beginning of tape */
  58.     unsigned char pad1        :2;    /* reserved */
  59.     unsigned char powerOnReset    :1;    /* Drive reset sinse last command */
  60.  
  61.     short    numRetries;        /* Number of retries */
  62.     short    underruns;        /* Number of underruns */
  63.     /*
  64.      * The following comes from the sysgen controller in copy commands
  65.      * which we don't use.
  66.      */
  67.     char numDiskBlocks[3];        /* Num disk blocks transferred */
  68.     char numTapeBlocks[3];        /* Num tape blocks transferred */
  69.  
  70. } DevQICIISense;            /* Known to be 16 Bytes big */
  71.  
  72.  
  73. /*
  74.  *----------------------------------------------------------------------
  75.  *
  76.  * DevSysgenAttach --
  77.  *
  78.  *    Verify and attach a Sysgen tape drive.
  79.  *
  80.  * Results:
  81.  *    SUCCESS if the device is a working Sysgen tape drive.
  82.  *    DEV_NO_DEVICE if the device is not a working Sysgen tape drive.
  83.  *
  84.  * Side effects:
  85.  *    Sets the type and call-back procedures.
  86.  *
  87.  *----------------------------------------------------------------------
  88.  */
  89. /*ARGSUSED*/
  90. ReturnStatus
  91. DevSysgenAttach(devicePtr, devPtr, tapePtr)
  92.     Fs_Device    *devicePtr;    /* Fs_Device being attached. */
  93.     ScsiDevice    *devPtr;    /* SCSI device handle for drive. */
  94.     ScsiTape    *tapePtr;    /* Tape drive state to be filled in. */
  95. {
  96.     unsigned char statusByte;
  97.     ScsiCmd    senseCmd;
  98.     char    senseData[SCSI_MAX_SENSE_LEN];
  99.     int        length;
  100.     ReturnStatus    status;
  101.  
  102.     /*
  103.      * Since we don't know about the inquiry data (if any) returned by 
  104.      * the Sysgen tape, check using the size of the SENSE data returned.
  105.      */
  106.     DevScsiSenseCmd(devPtr, SCSI_MAX_SENSE_LEN, senseData, &senseCmd);
  107.     status = DevScsiSendCmdSync(devPtr, &senseCmd, &statusByte, &length,
  108.                   (int *) NIL, (char *) NIL);
  109.     if ( (status != SUCCESS) || 
  110.          (statusByte != 0) ||
  111.      (length != SYSGEN_SENSE_BYTES)) {
  112.     return DEV_NO_DEVICE;
  113.     }
  114.     /*
  115.      * Take all the defaults for the tapePtr.
  116.      */
  117.     tapePtr->name = "Sysgen Tape";
  118.     return SUCCESS;
  119. }
  120.